package com.pptree.vo;

import java.util.ArrayList;
import java.util.List;

public class PageVo<T> {
	//当前页页码
	private int pageno = 1;
	//页容量：每页显示多少条记录
	private int pagesize = 10;
	//总记录数
	private int totalcount = 0;
	//总页数 
	private int totalpage = 0;
	//起始行的下标=(当前页页码 - 1) * 每页显示的数据量
	private int offset = 0;
	
	//数据源
	private List<T> list;

	
	public PageVo() {
		this.list = new ArrayList<T>();
	}

	public PageVo(int curPageNo,int pageSize){
		this.setPageno(curPageNo);
		this.setPagesize(pageSize);
	}

	public int getPageno() {
		return pageno;
	}


	public void setPageno(int pageno) {
		this.pageno = pageno;
	}


	public int getPagesize() {
		return pagesize;
	}


	public void setPagesize(int pagesize) {
		this.pagesize = pagesize;
	}


	public int getTotalcount() {
		return totalcount;
	}


	public void setTotalcount(int totalcount) {
		this.totalcount = totalcount;
	}


	public int getOffset() {
		this.offset = (this.pageno - 1) * this.pagesize;
		return this.offset;
	}


	public int getTotalpage() {
		if(this.totalcount > 0){
			this.totalpage = (this.totalcount % this.pagesize == 0) ? (this.totalcount / this.pagesize) : (this.totalcount / this.pagesize) + 1;
			return this.totalpage;
		}
		else{
			return 0;
		}
		
	}


	public List<T> getList() {
		return list;
	}


	public void setList(List<T> list) {
		this.list = list;
	}
	
	
}
 